<template>
	<view class="uni-product-list">
		<view class="uni-product" v-for="product in productList" :key="product.id" @click="goToProductDetail(product.id)">
			<view class="image-view">
				<image v-if="product.tupian" class="uni-product-image" :src="`http://localhost:8888${product.tupian}`">
				</image>
			</view>
			<view class="uni-product-title">{{product.zuopinmingcheng}}</view>
			<view class="uni-product-price">
				<text class="uni-product-price-original">摄影师：{{product.sheyingshixingming}}</text>
				<text class="uni-product-tip">{{product.lianxifangshi}}</text>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		jiaoshi
	} from "@/request/API/xinwentongzhi/index"; // 假设这是获取商品列表的API
	export default {
		/**
		 * 2020年12月9日  李新雷编写（练习）  适用所有app登录
		 * vue版本简洁又美观的登录页面（个人感觉插件市场的登录都不太好看，哈哈 O(∩_∩)O）
		 * 如果需要注册（注册可以设计在登录按钮下方），直接复制该页面稍微改动即可
		 */
		data() {
			return {
				productList: [],
			};
		},
		onShow() {
			this.getProducts()
		},
		methods: {
			getProducts() {
				jiaoshi({
					pageSize: 100,
					page: 1
				}).then(res => {
					this.productList = res.data.list;
				});
			},
			goToProductDetail(id) {
				console.log(id)
				uni.navigateTo({
					url: `/pages/qingxi/details?id=${id}`
				});
			}
		}
	};
</script>
<style>
	/* product */
	page {
		background: #F8F8F8;
	}

	view {
		font-size: 28upx;
	}

	.uni-product-list {
		display: flex;
		width: 100%;
		flex-wrap: wrap;
		flex-direction: row;
	}

	.uni-product {
		padding: 20upx;
		display: flex;
		flex-direction: column;
	}

	.image-view {
		height: 330upx;
		width: 330upx;
		margin: 12upx 0;
	}

	.uni-product-image {
		height: 330upx;
		width: 330upx;
		border-radius: 0.6rem;
	}

	.uni-product-title {
		width: 300upx;
		word-break: break-all;
		display: -webkit-box;
		overflow: hidden;
		line-height: 1.5;
		text-overflow: ellipsis;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}

	.uni-product-price {
		margin-top: 10upx;
		font-size: 28upx;
		line-height: 1.5;
		position: relative;
	}

	.uni-product-price-original {
		color: #e80080;
		width: 300upx;
		word-break: break-all;
		display: -webkit-box;
		overflow: hidden;
		line-height: 1.5;
		text-overflow: ellipsis;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}

	.uni-product-price-favour {
		color: #888888;
		text-decoration: line-through;
		margin-left: 10upx;
	}

	.uni-product-tip {
		/* position: absolute; */
		right: 10rpx;
		background-color: #ff3333;
		color: #ffffff;
		padding: 0 10rpx;
		border-radius: 5rpx;
		font-size: 0.7rem;
		top: -382rpx;
	}
</style>